{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you want to make a plot, change the folder name <br>\n",
    "after installing plotly,cufflink and run the following code.<br>\n",
    "```folder_name='new_results'```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-02-27T07:36:57.526429Z",
     "start_time": "2021-02-27T07:36:56.621129Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os,time\n",
    "import glob\n",
    "import cufflinks as cf\n",
    "import plotly.offline\n",
    "cf.go_offline()\n",
    "cf.set_config_file(offline=True, world_readable=True)\n",
    "import torchvision.models as models"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-02-27T07:36:57.529849Z",
     "start_time": "2021-02-27T07:36:57.527382Z"
    }
   },
   "outputs": [],
   "source": [
    "MODEL_LIST = {\n",
    "    'mnasnet':models.mnasnet.__all__[1:],\n",
    "    'resnet': models.resnet.__all__[1:],\n",
    "    'densenet': models.densenet.__all__[1:],\n",
    "    'squeezenet': models.squeezenet.__all__[1:],\n",
    "    'vgg': models.vgg.__all__[1:],\n",
    "    'mobilenet':models.mobilenet.__all__[1:],\n",
    "    'shufflenetv2':models.shufflenetv2.__all__[1:]\n",
    "}\n",
    "folder_name='result/'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-02-27T07:36:57.533380Z",
     "start_time": "2021-02-27T07:36:57.530956Z"
    }
   },
   "outputs": [],
   "source": [
    "csv_list=glob.glob(folder_name+'/*.csv')\n",
    "columes=[]\n",
    "for key,values in MODEL_LIST.items():\n",
    "    for i in values:\n",
    "        columes.append((key,i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-02-27T07:38:26.809924Z",
     "start_time": "2021-02-27T07:36:57.534123Z"
    }
   },
   "outputs": [],
   "source": [
    "for csv in csv_list:\n",
    "    df=pd.read_csv(csv)\n",
    "    df.columns = pd.MultiIndex.from_tuples(columes)\n",
    "    df.groupby(level=0,axis=1).mean().mean()\n",
    "#     print(csv)\n",
    "    title=csv.split('/')[1].split('_benchmark')[0]\n",
    "    title=title.replace(' ','_')\n",
    "    df.groupby(level=0,axis=1).mean().mean().iplot(kind='scatter',mode='markers',title=title,yTitle='time(ms)',xTitle='models',asImage=True,filename=title)\n",
    "    for model in MODEL_LIST.keys():\n",
    "        df.mean()[model].iplot(kind='scatter',mode='markers',title=model+\"_\"+title,yTitle='time(ms)',xTitle='models',asImage=True,filename=model+\"_\"+title)\n",
    "        time.sleep(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
